package com.ruoyi.business.projectRecord.controller;

import com.ruoyi.business.projectRecord.domain.ProjectRecord;
import com.ruoyi.business.projectRecord.service.ProjectRecordService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 针对表【PROJECT_RECORD】的数据库操作Controller
 *
 * @author 毕京瑞
 * @createTime 2023-07-05 15:00
 */
@RestController
@RequestMapping("/business/projectRecord")
public class ProjectRecordController extends BaseController {
	
	@Autowired
	private ProjectRecordService projectRecordService;
	
	/**
	 * 根据参数获取【PROJECT_RECORD】列表
	 *
	 * @param projectRecord
	 * @return
	 */
	@GetMapping("/list")
	public TableDataInfo list(ProjectRecord projectRecord) {
		startPage();
		// List<ProjectRecord> list = projectRecordService.listByParams(projectRecord);
		// TODO: 实现查询逻辑
		// return getDataTable(list);
		return null;
	}
	
	/**
	 * 根据id获取【PROJECT_RECORD】详细信息
	 *
	 * @param id
	 * @return
	 */
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable Long id) {
		return AjaxResult.success(projectRecordService.getById(id));
	}
	
	/**
	 * 新增【PROJECT_RECORD】
	 */
	@PostMapping
	@Log(title = "PROJECT_RECORD表新增项目", businessType = BusinessType.INSERT)
	public AjaxResult add(@Validated @RequestBody ProjectRecord projectRecord) {
		return AjaxResult.success(projectRecordService.save(projectRecord));
	}
	
	/**
	 * 修改【PROJECT_RECORD】
	 */
	@PutMapping
	@Log(title = "PROJECT_RECORD表修改项目", businessType = BusinessType.UPDATE)
	public AjaxResult edit(@Validated @RequestBody ProjectRecord projectRecord) {
		return AjaxResult.success(projectRecordService.updateById(projectRecord));
	}
	
	/**
	 * 删除【PROJECT_RECORD】
	 */
	@DeleteMapping("/{ids}")
	@Log(title = "PROJECT_RECORD表删除项目", businessType = BusinessType.DELETE)
	public AjaxResult remove(@PathVariable Long[] ids) {
		return AjaxResult.success(projectRecordService.removeByIds(Arrays.asList(ids)));
	}
}
